﻿using System;
using System.Collections.Generic;
using System.Text;
using Silvermoon.UI;
using Silvermoon.Windows;
using System.Drawing;

namespace Silvermoon.Controls
{
    public static class ButtonStateManagers
    {

        public static readonly VisualStateManager BaseManager = new VisualStateManager(
            new VisualStateGroup(
                new VisualState(VState.Unchecked, 225),
                VisualState.Normal,
                new VisualState(VState.Pressed,
                    new ScaleTransition
                    {
                        To = new ScaleTransform(0.91f, 0.91f, 1f),
                        Duration = 5,
                    }
                )
            )
         );

        public static readonly VisualStateGroup NormalPressedButtonGroup =
             new VisualStateGroup(
                new VisualState(VState.Normal) { Duration = 500 },
                 new VisualState(VState.Pressed, new ScaleTransition { To = new ScaleTransform(0.91f, 0.91f, 1f), Duration = 5, })
             );

        public static readonly VisualStateManager MetroStateManager =
            new VisualStateManager(
                 Control.OpacityDisabledEnabledGroup,
                 new VisualStateGroup(
                    new VisualState(VState.Normal,
                         new ColorTransition(Control.ColorProperty, 5, null, null),
                         new ColorTransition(Control.TextColorProperty, 5, null, null),
                         new ScaleTransition { To = ScaleTransform.One, Duration = 350, }),

                     new VisualState(VState.Pressed,
                         new ColorTransition(Control.ColorProperty, 5, null, PhoneColors.White),
                         new ColorTransition(Control.TextColorProperty, 5, null, PhoneColors.Black),
                         new ScaleTransition { To = new ScaleTransform(0.91f, 0.91f, 1f), Duration = 5, })
                 ));

        public static readonly VisualStateManager ButtonManager = new VisualStateManager(
            Control.ColorDisabledEnabledGroup,
            NormalPressedButtonGroup
         );

        public static readonly VisualStateManager PickerManager = new VisualStateManager(
            new VisualStateGroup(
                new VisualState(VState.Enabled, 30),
                new VisualState(VState.Disabled,
                    new IntTransition(ChromeControl.BackgroundOpacityProperty, 5, null, 0),
                    new ColorTransition(Control.TextColorProperty, 5, null, PhoneColors.Medium),
                    new IntTransition(ChromeControl.OpacityProperty, 5, null, 128))
                ),

            new VisualStateGroup(
                new VisualState(VState.Normal, 30),
                new VisualState(VState.Pressed,
                    new ColorTransition(Control.ColorProperty, 5, null, PhoneColors.White),
                                             new ScaleTransition { To = new ScaleTransform(0.96f, 0.96f, 1f), Duration = 5, })
                )
         );


        public static readonly VisualStateManager RadioButtonManager = new VisualStateManager(
            new VisualStateGroup(
                new VisualState(VState.Enabled, 1),
                new VisualState(VState.Disabled,
                    new IntTransition(RadioButton.OpacityProperty, 1, null, 128),
                    new ColorTransition(RadioButton.CheckColorProperty, 1, null, PhoneColors.MediumDark)
                 )),
            new VisualStateGroup(
                new VisualState(VState.Unchecked, 1),
                new VisualState(VState.Checked,
                    new ColorTransition(1, null, PhoneColors.White)
                )
                ),
            new VisualStateGroup(
                new VisualState(VState.Normal, 1),
                new VisualState(VState.Pressed,
                    new ColorTransition(1, null, PhoneColors.White)
                )
         ));

    }
}
